
export interface ResponseType<T = {}> {
    code: number;
    msg: string;
    data: T
}

interface ListProps<P> {
    [id: string]: P;
}

export interface GlobalDataProps {
    token: string;
    columns: { data: ListProps<ColumnProps>; currentPage: number; total: number };
    posts: { data: ListProps<PostProps>; loadedColumns: string[] };
    user: UserProps;
    loading: boolean;
    error: GlobalErrorProps;
}

export interface GlobalErrorProps {
    status: boolean;
    message?: string;
}

// 列表
export interface ColumnProps {
    _id: string;
    title: string;
    avatar?: ImageProps;
    description: string;
}

export interface PostProps {
    _id?: string;
    title: string;
    excerpt?: string;   // 摘要
    content?: string;
    image?: ImageProps | string;
    createdAt?: string;
    column: string;
    author?: string | UserProps;
    isHTML?: boolean;
}

// components
// globalHeader

export interface UserProps {
    isLogin: boolean;
    nickName?: string;
    _id?: string;
    column?: string;
    email?: string;
    avatar?: ImageProps;
    description?: string;
}

export interface ImageProps {
    fitUrl?: string;
    _id?: string;
    url?: string;
    createdAt?: string;
}

// form
interface RuleProp {
    type: 'required' | 'email' | 'min' | 'max' | 'custom';
    message: string;
    length?: number;
    validator?: () => boolean
}

export type RulesProp = RuleProp[];
export type TagType = 'input' | 'textarea';